package com.cndw.kungfu.socket;

import java.util.HashMap;
import java.util.Map;

import message.push.util.MD5;
import message.push.util.TimeProcesser;
import flex.messaging.io.SerializationContext;

public class Test {
	
	public static SerializationContext context;
	
	private static String loginKey = "1e9ffb02-664a-419f-800e-e3c3ca23cf93";
	private static String partnerEName = "localhost";
//	private static String partnerEName = "tencent";
	private static String pf = "pengyou";
	private static String loginExt = "1,0,openkey,pfkey,0,0,0";
//	private static String loginExt = "1,1,E993E14B00E0E6C227404646E386749E,12f3c3c0122879fc353f4252c6311088,0,0,0";
	
//	private static String openId = "F33E27800D1B02B3C96D1475FF4B5D5A";
	private static String openId = "eee";
	static {
		context = new SerializationContext();
		context.legacyCollection = true;
	}
	
	public static void main(String[] args) {
//		Client.start(1, "s11.app100622837.qqopenapp.com", 8001);
		Client.start(5, "127.0.0.1", 7782);
		SocketRequest request = new SocketRequest(5, "LoginController", "auth", new Object[] { loginParams() });
		SocketResponse response = Client.sendRequest(request);
		System.out.println(response.getM());
	}
	
	public static Map<String, Object> loginParams() {
		int time = TimeProcesser.getUnixTime();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("openId", openId);
		map.put("time", time + "");
		map.put("pf", pf);
		String sign = MD5.compile(partnerEName+","+openId+ "," + time +"," + pf +","+ loginExt+"," + loginKey);
		map.put("sign", sign);
		map.put("ext", loginExt);
		return map;
	}

}
